package hivi.vn.hivigold.activities;

import hivi.vn.hivigold.R;
import hivi.vn.hivigold.utils.AccessDenied;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class Main extends Activity {
	ImageView btnGoldPrice;
	ImageView btnLCD;
	ImageView btnVoucher;
	ImageView btnReport;
	TextView tvGoldPrice;
	TextView tvLCD;
	TextView tvVoucher;
	TextView tvReport;
	ImageView btnSetting;
	TextView tvSetting;
	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.home_layout);

		btnGoldPrice = (ImageView) findViewById(R.id.btnPrice);
		btnLCD = (ImageView) findViewById(R.id.btnLCD);
		btnVoucher = (ImageView) findViewById(R.id.btnTransaction);
		btnReport = (ImageView) findViewById(R.id.btnReport);
		btnSetting = (ImageView) findViewById(R.id.btnSetting);
		tvGoldPrice = (TextView) findViewById(R.id.tvPrice);
		tvLCD = (TextView) findViewById(R.id.tvLCD);
		tvVoucher = (TextView) findViewById(R.id.tvTransaction);
		tvReport = (TextView) findViewById(R.id.tvReport);
		tvSetting = (TextView) findViewById(R.id.tvSetting);
		
		btnGoldPrice.setOnClickListener(onClickListener);
		tvGoldPrice.setOnClickListener(onClickListener);
		btnVoucher.setOnClickListener(onClickListener);
		btnSetting.setOnClickListener(onClickListener);
		tvVoucher.setOnClickListener(onClickListener);
		btnLCD.setOnClickListener(onClickListener);
		tvLCD.setOnClickListener(onClickListener);
		tvSetting.setOnClickListener(onClickListener);
		btnReport.setOnClickListener(onClickListener);
		tvReport.setOnClickListener(onClickListener);
	}

	OnClickListener onClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.btnPrice:
				if (!AccessDenied.KCB) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				GoldPriceActivity.onStartIntent(getBaseContext());
				break;
			case R.id.tvPrice:
				if (!AccessDenied.KCB) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				GoldPriceActivity.onStartIntent(getBaseContext());
				break;
			case R.id.btnLCD:
				LCDSetting.onStartIntent(getBaseContext());
				break;
			case R.id.tvLCD:
				LCDSetting.onStartIntent(getBaseContext());
				break;
			case R.id.btnTransaction:
				if (!AccessDenied.HD0) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				VoucherActivity.onStartIntent(getBaseContext());
				break;
			case R.id.tvTransaction:
				if (!AccessDenied.HD0) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				VoucherActivity.onStartIntent(getBaseContext());
				break;
			case R.id.btnReport:
				if (!AccessDenied.BC4) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				ReportActivity.onStartIntent(getBaseContext());
				break;
			case R.id.tvReport:
				if (!AccessDenied.BC4) {
					Toast.makeText(getBaseContext(), R.string.warning_access_denied,
							Toast.LENGTH_LONG).show();
					return;
				}
				ReportActivity.onStartIntent(getBaseContext());
				break;
			case R.id.tvSetting:
				SettingActivities.onStartIntent(getBaseContext());
				break;
			case R.id.btnSetting:
				SettingActivities.onStartIntent(getBaseContext());
				break;
			}
		}
	};
}
